home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_oth / forchek1 / forchek.hlp < prev    next >
Text File  |  1991-10-28  |  16KB  |  293 lines

  1.  
  2.  
  3.  
  4. 1 FORCHEK
  5.  Fortran program checker.
  6. 2 Introduction
  7.  
  8.  
  9.       Forchek (short  for  Fortran  checker)  is  designed  to  detect
  10.  certain errors in a Fortran program that a compiler usually does not.
  11.  Forchek is not primarily  intended  to  detect  syntax  errors.   Its
  12.  purpose  is  to assist the user in finding semantic errors.  Semantic
  13.  errors are legal in the Fortran language  but  are  wasteful  or  may
  14.  cause  incorrect  operation.   For example, variables which are never
  15.  used  may  indicate  some  omission  in  the  program;  uninitialized
  16.  variables  contain  garbage  which  may cause incorrect results to be
  17.  calculated; and variables which are not declared  may  not  have  the
  18.  intended  type.  Forchek is intended to assist users in the debugging
  19.  of their Fortran program.  It is not intended  to  catch  all  syntax
  20.  errors.   This  is  the  function  of  the  compiler.  Prior to using
  21.  Forchek, the user should verify that the program compiles correctly.
  22.  
  23.       For more detailed information, consult the documentation.
  24. 2 Invoking_Forchek
  25.  
  26.  Forchek is invoked through a command of the form:
  27.  
  28.      $ forchek [/option /option ...] filename [filename ...]
  29.  
  30.  (The brackets indicate something which  is  optional.   The  brackets
  31.  themselves  are  not  actually  typed.) Here options are command-line
  32.  switches or settings, which control the operation of the program  and
  33.  the  amount of information that will be printed out.  If no option is
  34.  specified, the default action is to print error  messages,  warnings,
  35.  and  informational  messages,  but  not the program listing or symbol
  36.  tables.
  37.  
  38.       Each option begins with the '/' character.  (Forchek also allows
  39.  the '-' character to be used.)
  40. 2 Files
  41.  
  42.  
  43.       When giving a name of an input file, the extension is  optional.
  44.  If  no extension is given, Forchek will first look for a project file
  45.  with extension '.prj' and will use that if it exists.  If  not,  then
  46.  Forchek will look for a Fortran source file with the extension '.for'
  47.  for VMS systems, '.f' for Unix systems.  More than one file name  can
  48.  be  given to Forchek, and it will process the modules in all files as
  49.  if they were in a single file.
  50.  
  51.       If no filename is  given,  Forchek  will  read  input  from  the
  52.  standard input.
  53. 2 Options
  54.  
  55.  Forchek options fall into two categories:  switches, which are either
  56.  true  or  false,  and settings, which have a numeric or string value.
  57.  The name of a switch can be preceded by 'no' to turn  it  off:   e.g.
  58.  /nousage  would turn off the warnings about variable usage.  Only the
  59.  first 3 characters of an option name (not counting the '/')  need  be
  60.  provided.
  61. 3 /columns=n
  62.  Set maximum line length to n columns.  (Beyond this is ignored.) This
  63.  setting  is  provided to allow checking of programs which may violate
  64.  the Fortran standard limit of 72 columns for the length  of  a  line.
  65.  According to the standard, all characters past column 72 are ignored.
  66.  This setting does not affect the reporting of overlength lines  under
  67.  the /f77 option.  Max is 132.  Default = 72.
  68. 3 /common=n
  69.  This setting varies the strictness  of  checking  of  common  blocks.
  70.  Level  3 is the strictest:  it requires that in each declaration of a
  71.  given common block, corresponding variables agree in  data  type  and
  72.  (if  arrays)  size  and number of dimensions.  Levels 1 and 2 require
  73.  only that corresponding memory locations agree  in  data  type.   The
  74.  difference between Levels 1 and 2 is that Level 2 warns if the blocks
  75.  are not equal in total length, while  Level  1  does  not.   Level  0
  76.  suppresses all checking.  Default = 3.
  77. 3 /declare
  78.  If this flag is set, all identifiers whose datatype is  not  declared
  79.  in  each  module  will be listed.  This flag is useful for helping to
  80.  find misspelled variable names, etc.  The same listing will be  given
  81.  if the module contains an IMPLICIT NONE statement.  Default = no.
  82. 3 /division
  83.  This switch is provided to help users spot potential division by zero
  84.  problems.   If  this  switch  is selected, every division except by a
  85.  constant  will  be  flagged.   (It  is  assumed  that  the  user   is
  86.  intelligent  enough  not  to  divide  by a constant which is equal to
  87.  zero!) Default = no.
  88. 3 /extern
  89.  Causes Forchek to report  whether  any  subprograms  invoked  by  the
  90.  program  are  never defined, or are multiply defined.  Ordinarily, if
  91.  Forchek is being run on a complete  program,  each  subprogram  other
  92.  than  the  intrinsic  functions  should be defined once and only once
  93.  somewhere.  Turn off this switch if you just want to check  a  subset
  94.  of  files  which  form part of a larger complete program, or to check
  95.  all at once a number of unrelated files which might each  contain  an
  96.  unnamed main program.  Subprogram arguments will still be checked for
  97.  correctness.  Default = yes.
  98. 3 /f77
  99.  Use this flag to catch language extensions which violate the  Fortran
  100.  77  standard.   Such  extensions  may  cause  your  program not to be
  101.  portable.  Examples include the use of underscores in variable names;
  102.  variable  names  longer  than  six characters; statement lines longer
  103.  than 72 characters; and nonstandard statements such  as  the  DO  ...
  104.  ENDDO  structure.   Forchek  does  not report on the use of lowercase
  105.  letters.  Default=no.
  106. 3 /library
  107.  This switch is used when a number of subprograms are contained  in  a
  108.  file,  but  not  all  of them are used by the application.  Normally,
  109.  Forchek warns you if any subprograms  are  defined  but  never  used.
  110.  This switch will suppress these warnings.  Default = no.
  111. 3 /linebreak
  112.  Normally, when scanning a statement which is continued onto the  next
  113.  line,  Forchek  treats the end of the line as a space.  This behavior
  114.  is the same as for Pascal and C, and also corresponds to  how  humans
  115.  normally  would  read  and write programs.  However, occasionally one
  116.  would like to use Forchek to check a program in which identifiers and
  117.  keywords  are  split  across  lines,  for instance programs which are
  118.  produced using a preprocessor.  Choosing the option /nolinebreak will
  119.  cause Forchek to skip over the end of line and also any leading space
  120.  on the continuation line (from the continuation mark up to the  first
  121.  nonspace character).  Default = yes, i.e.  treat linebreaks as space.
  122.  
  123.       Note  that  in  nolinebreak  mode,  if  token  pairs   requiring
  124.  intervening  space  (for  instance, GOTO 100) are separated only by a
  125.  linebreak, they will be rejoined.
  126.  
  127.       Also, tokens requiring more than one character of lookahead  for
  128.  the  resolution  of  ambiguities  must not be split across lines.  In
  129.  particular, a complex constant may not be split across a line.
  130. 3 /list
  131.  Specifies that a listing of the Fortran program is to be printed  out
  132.  with  line  numbers.   If Forchek detects an error, the error message
  133.  follows the program line with a caret (^) specifying the location  of
  134.  the  error.   If  no source listing was requested, Forchek will still
  135.  print  out  any  line  containing  an  error,  to  aid  the  user  in
  136.  determining where the error occurred.  Default = no.
  137. 3 /novice=n
  138.  This setting controls certain messages  about  conditions  which  are
  139.  likely  to  be  errors  for  novice  programmers, but which are often
  140.  intentional  by  more  sophisticated  programmers.   Some  of   these
  141.  warnings  deal with cases in which Forchek suspects that what appears
  142.  to be a function is intended to be an array, which the user forgot to
  143.  declare in a DIMENSION statement.  Since a function invocation and an
  144.  array reference  are  identical  in  syntax,  undeclared  arrays  are
  145.  interpreted  by  the  Fortran  compiler  and by Forchek as functions.
  146.  Novice users  are  often  confused  by  the  messages  which  result.
  147.  Forchek attempts to remedy this confusion.  Default level = 1.
  148.  
  149.       The novice levels are given below.  The warning corresponding to
  150.  each  number will be suppressed if the novice level is set to greater
  151.  than that value.
  152.  
  153.          1.  Warn if arrays passed as arguments to a subprogram do not
  154.             match  the corresponding dummy arguments in both number of
  155.             dimensions and size.  Exception:  if the declared size  of
  156.             the  dummy array is 1 or if it is dimensioned with a dummy
  157.             variable, only the number of dimensions will be checked.
  158.  
  159.          2.  Warn the user if any argument of a subprogram appears  to
  160.             be  a  function.   This warning is suppressed if the dummy
  161.             argument is declared in  an  EXTERNAL  statement.   Novice
  162.             programmers  seldom  pass  functions  as  arguments  of  a
  163.             subprogram, so it is more likely that such an argument was
  164.             intended to be an array, but was not dimensioned.
  165.  
  166.          3.  If a function was invoked but never defined,  advise  the
  167.             user  that  it  may be an array which was not dimensioned.
  168.             This warning is suppressed if the function is declared  in
  169.             an  EXTERNAL  or  INTRINSIC statement in any module of the
  170.             program.  This warning is  completely  suppressed  by  the
  171.             /noextern option.
  172.  
  173.          4.  Warn if  a  function  has  side  effects:   i.e.   if  it
  174.             modifies  any  of its arguments, or modifies a variable in
  175.             common.  Ideally, a function has no side effects, and acts
  176.             only  by computing a value based on its arguments, whereas
  177.             a subroutine normally acts through side effects.  Advanced
  178.             programmers  sometimes  wish  to combine the features of a
  179.             subroutine and a function in a single module.
  180. 3 /output=filename
  181.  This setting is provided for convenience  on  systems  which  do  not
  182.  allow easy redirection of output from programs.  When this setting is
  183.  given, the output which normally appears on the screen will  be  sent
  184.  instead to the named file.  Note, however, that operational errors of
  185.  Forchek itself (e.g.  out of space or cannot open file) will still be
  186.  sent  to the screen.  The extension for the filename is optional, and
  187.  if no extension is given, the extension .lis will be used.
  188. 3 /portability
  189.  Forchek will give warnings for  a  variety  of  non-portable  usages.
  190.  These  include  the use of tabs except in comments or inside strings,
  191.  the use of hollerith constants, and the equivalencing of variables of
  192.  different  data  types.   This  option  does not produce warnings for
  193.  violations  of  the  Fortran  77  standard,  which  may  also   cause
  194.  portability  problems.  To catch those, use the /f77 option.  Default
  195.  = no.
  196. 3 /project
  197.  Forchek will create a project file from  each  source  file  that  is
  198.  input  while  this flag is in effect.  The project file will be given
  199.  the same name as the input file,  but  with  the  extension  '.f'  or
  200.  '.for'  replaced  by  '.prj'.   (If input is from standard input, the
  201.  project file is named forchek.prj.) Default = no.
  202.  
  203.  A project file contains a summary  of  information  from  the  source
  204.  file,  for  use in checking agreement among function, subroutine, and
  205.  common block usages in other files.  It allows incremental  checking,
  206.  which  saves  time  whenever you have a large set of files containing
  207.  shared subroutines, most of which seldom change.  You can run Forchek
  208.  once  on  each  file with the /project flag set, creating the project
  209.  files.  Usually you would also set the /library and  /noextern  flags
  210.  at this time, to suppress messages relating to consistency with other
  211.  files.  Only error messages pertaining to each file by itself will be
  212.  printed at this time.  Thereafter, run Forchek without these flags on
  213.  all the project  files  together,  to  check  consistency  among  the
  214.  different  files.  All messages internal to the individual files will
  215.  now be omitted.  Only when a file is altered will a new project  file
  216.  need to be made for it.
  217.  
  218.       The information saved  in  the  project  file  consists  of  all
  219.  subprogram  declarations,  all subprogram invocations not resolved by
  220.  declarations in the same file, and one instance of each common  block
  221.  declaration.    Thus  project  files  contain  only  information  for
  222.  checking agreement between files.  This means that a project file  is
  223.  of  no  use if all modules of the complete program are contained in a
  224.  single file.
  225.  
  226.       Naturally, when the /project flag is set, Forchek will not  read
  227.  project files as input.
  228. 3 /sixchar
  229.  One of the goals of the Forchek program is to  help  users  to  write
  230.  portable Fortran programs.  One potential source of nonportability is
  231.  the use of variable names that are longer than six characters.   Some
  232.  compilers  just  ignore  the  extra  characters.  This behavior could
  233.  potentially lead to two different variables being considered  as  the
  234.  same.  For instance, variables named AVERAGECOST and AVERAGEPRICE are
  235.  the same in the first six characters.  If  you  wish  to  catch  such
  236.  possible conflicts, use this flag.  Default = no.
  237. 3 /symtab
  238.  A symbol table will be printed  out  for  each  module,  listing  all
  239.  identifiers  mentioned  in  the module.  This table gives the name of
  240.  each variable, its datatype, and the number of dimensions for arrays.
  241.  An  asterisk  (*)  indicates  that  the  variable has been implicitly
  242.  typed, rather than  being  named  in  an  explicit  type  declaration
  243.  statement.   The  table  also  lists  all  subprograms invoked by the
  244.  module, all common blocks declared, etc.  Default = no.
  245. 3 /usage
  246.  This switch is  on  by  default.   It  causes  Forchek  to  list  all
  247.  variables which may be used before they are initialized, or which are
  248.  given a value but never subsequently used, or which are declared  but
  249.  never  used.   Sometimes Forchek makes a mistake about this.  Usually
  250.  it errs on the side of giving a warning where no problem exists,  but
  251.  in rare cases it will fail to warn where the problem does exist.  See
  252.  the section on bugs for examples.  If variables are equivalenced, the
  253.  rule  used by Forchek is that a reference to any variable implies the
  254.  same reference to all variables it is  equivalenced  to.   Default  =
  255.  yes.
  256. 3 /verbose
  257.  This option is on by default.  Turning it off reduces the  amount  of
  258.  output  relating to normal operation, so that error messages are more
  259.  apparent.  This option is provided for the convenience of  users  who
  260.  are  checking  large suites of files.  The eliminated output includes
  261.  the names of project files, and the message reporting that no  syntax
  262.  errors  were  found.   (Some  of this output is turned back on by the
  263.  /list and /symtab options.) Default = yes.
  264. 2 Changing_the_defaults
  265.  
  266.       Forchek includes a mechanism for changing the default values  of
  267.  all  options  by defining environment variables.  When Forchek starts
  268.  up, it looks in its environment for any  variables  whose  names  are
  269.  composed  by  prefixing  the  string  "FORCHEK_"  onto the uppercased
  270.  version of the option name (the quote  marks  are  not  part  of  the
  271.  name.)  If such a variable is found, its value is used to specify the
  272.  default for the corresponding switch or  setting.   In  the  case  of
  273.  settings (for example, the novice level) the value of the environment
  274.  variable is read as the  default  setting  value.   In  the  case  of
  275.  switches,  the  default  switch will be taken as true or "YES" unless
  276.  the environment variable has the value "0" or "NO" (again, the quotes
  277.  are  not  part  of  the value).  Of course, command-line options will
  278.  override these defaults the same way as they  override  the  built-in
  279.  defaults.
  280.  
  281.       Note that the environment variable name must be constructed with
  282.  the  full-length  option  name,  which  must  be  in  uppercase.  For
  283.  example, to make Forchek print a source listing by default,  set  the
  284.  environment variable "FORCHEK_LIST" to "1" or "YES" or anything other
  285.  than "0" or "NO".  The names "FORCHEK_LIS" (not the full option name)
  286.  or  "forchek_list"  (lower case) would not be recognized.  The way to
  287.  set the environment variables on the VAX/VMS system is by  using  the
  288.  DEFINE  command.   For  example,  to  set the default /list switch to
  289.  "YES", give the command
  290.  
  291.      $ DEFINE FORCHEK_LIST 1
  292.  
  293.